package com.guchenbo.lssp.pool;

/**
 * @author guchenbo
 */
public class AbstractSessionSource {
    public static final int DEFAULT_INITIAL_SIZE = 1;
    public static final int DEFAULT_MAX_ACTIVE_SIZE = 2;
    public static final long DEFAULT_MAX_WAIT_MILLIS = 15 * 1000L;
    public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 60 * 1000L;

    /**
     * 名称
     */
    protected String name;
    /**
     * 是否初始化过
     */
    protected volatile boolean inited = false;
    /**
     * 是否可用
     */
    protected volatile boolean closed = false;
    /**
     * 资源池初始大小
     */
    protected volatile int initialSize = DEFAULT_INITIAL_SIZE;
    /**
     * 资源池最大数量
     */
    protected volatile int maxActive = DEFAULT_MAX_ACTIVE_SIZE;
    /**
     * 资源池最小数量
     */
    protected volatile int minIdle = DEFAULT_INITIAL_SIZE;
    /**
     * 获取资源超时时间
     */
    protected volatile long maxWaitMillis = DEFAULT_MAX_WAIT_MILLIS;
    /**
     * 资源池自我检测时间，用于定时检测并且保持资源池最小数量
     */
    protected volatile long timeBetweenEvictionRunsMillis = DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
    /**
     * 是否开启共享模式
     * 开启共享模式，可以节约session
     */
    protected volatile boolean shared = false;

    public int getInitialSize() {
        return initialSize;
    }

    public void setInitialSize(int initialSize) {
        this.initialSize = initialSize;
    }

    public int getMaxActive() {
        return maxActive;
    }

    public void setMaxActive(int maxActive) {
        this.maxActive = maxActive;
    }

    public int getMinIdle() {
        return minIdle;
    }

    public void setMinIdle(int minIdle) {
        this.minIdle = minIdle;
    }

    public long getMaxWaitMillis() {
        return maxWaitMillis;
    }

    public void setMaxWaitMillis(long maxWaitMillis) {
        this.maxWaitMillis = maxWaitMillis;
    }

    public long getTimeBetweenEvictionRunsMillis() {
        return timeBetweenEvictionRunsMillis;
    }

    public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
    }

    public boolean isShared() {
        return shared;
    }

    public void setShared(boolean shared) {
        this.shared = shared;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
